package com.fs.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fs.dao.ProductDao;
import com.fs.entity.Product;
@WebServlet("/spQuery")
public class SpQueryServlet extends HttpServlet {
		@Override
		protected void doGet(HttpServletRequest req, HttpServletResponse resp)
				throws ServletException, IOException {
			doPost(req, resp);
		}
		
		@Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
			req.setCharacterEncoding("utf-8");//设置请求编码格式
			resp.setContentType("text/html;charset=utf-8");//设置响应的编码格式
			resp.setCharacterEncoding("utf-8");
			String type =req.getParameter("type");
			PrintWriter out = resp.getWriter();
			ProductDao prodao=new ProductDao();
			List<Product> prolist=prodao.getProductListAll();
			req.setAttribute("prolist",prolist );
			req.getRequestDispatcher("index.jsp").forward(req, resp);
		}
}
